// app.ts

App<IAppOption>({
  globalData: {
    statusHeight: 0,
    navHeight: 0,
    safeAreaBottom: 0,
    MenuButtonBoundingClientRect: {},
    MenuTree: [],
    listeners: [], // 存储监听器函数的数组
  },
  onLaunch() {    
    let res = wx.getSystemInfoSync();
    const statusHeight = res.statusBarHeight
    const MenuButtonBoundingClientRect = wx.getMenuButtonBoundingClientRect()
    
    this.globalData.statusHeight = statusHeight
    this.globalData.MenuButtonBoundingClientRect = MenuButtonBoundingClientRect

    this.globalData.navHeight = MenuButtonBoundingClientRect.height + (MenuButtonBoundingClientRect.top - statusHeight)
    this.globalData.safeAreaBottom = res.safeArea.bottom - res.safeArea.height
  },
  
  registerListener: function (listener) {
    this.globalData.listeners.push(listener);
  },
  // 触发监听器函数的方法
  triggerListeners: function () {
    console.log('坚挺触发')
    var listeners = this.globalData.listeners;
    for (var i = 0; i < listeners.length; i++) {
      listeners[i]();
    }
  }
})